package IO;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.Reader;
import java.util.Map;
import java.util.Set;

import Dictionary.Dictionary;

public class Input {
	final  String DEAFULT_FILE_ADDRESS="GB2312Dic";
	File file=new File(DEAFULT_FILE_ADDRESS);
	InputStream in=null;
	Reader reader = null;
	byte[] bytes = new byte[(int) file.length()];
	
	 /**
     * 根据文件名 读取文件
     * @param 文件路径(C:\123.txt)或者同文件下的(1.txt) 或者项目根路径下(0.txt)
     * @return List<String> 
     * @author wdj
     * */
    void readFileByBytes(String fileName){
    	if(null!=fileName&&!"".equals(fileName)){
    		file=new File(fileName);
    		bytes= new byte[(int) file.length()];
    	}
	    try {
	    	//in=null;
			in=new FileInputStream(file);
			int tempbyte;
			while((tempbyte=in.read())!=-1){
				System.out.println(tempbyte);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
   }
    /**
     * 根据文件名 读取文件
     * @param 文件路径(C:\123.txt)或者同文件下的(1.txt) 或者项目根路径下(0.txt)
     * @return List<String> 
     * @author wdj
     * */
    void  readFileByChar(String fileName){
    	if(null!=fileName&&!"".equals(fileName)){
    		file=new File(fileName);
    	}
	    try {
	    	
	    }
	    catch (Exception e) {
	    	
		}
    	
    	
    }
    /**
     * 根据文件名 读取文件
     * @param 文件路径(C:\123.txt)或者同文件下的(1.txt) 或者项目根路径下(0.txt)
     * @return List<String> 
     * @author wdj
     * */
    void  readFileByFileInputStream(String fileName){
    	if(null!=fileName&&!"".equals(fileName)){
    		file=new File(fileName);
    		bytes= new byte[(int) file.length()];
    	}
    	try {
			FileInputStream fis = new FileInputStream(file);
			fis.read(bytes, 0, bytes.length);
			fis.close();
    	 }
	    catch (Exception e) {
			e.printStackTrace();
		}
    }
  
    public static void main(String[] args) throws Exception{
    	/*ReadFile read=new ReadFile();
    	Map<String ,String[]> map=read.readDicToMap("GB2312Dic");*/

    	Dictionary dic=new Dictionary();
    	for(String str:dic.getKeyByValue(dic.loadDicToMap("GB2312Dic"),"ding")){
    		System.out.println(str);
    	}
	}
}
